<div ng-controller="chainBindUserCtrl">
    <div class="bg-light lter b-b wrapper-md ng-scope">
        <h4 class="m-n font-thin">用户绑定</h4>
        <button onClick="javascript: history.go(-1);" class="btn-back btn btn-dark btn-sm btn-rounded">
            返回
        </button>
    </div>
    <div class="wrapper">
        <div class="panel-body panel">
            <div>
                <div class="padder-md padder-v bg-light m-b-sm w-full inline">
                    <span class="font-bold">已经绑定相应用户</span>
                    <button class="btn btn-success btn-sm pull-right" ng-click="addShow=!addShow"><i class="fa fa-plus"></i>绑定新用户</button>
                </div>
                <div>
                    <div class="inline m-r-xs fa-border" ng-repeat="item in bindUsers">
                        <div>
                            <div class="panel-body m-n">
                                <div class="pull-left m-r-sm text-center">
                                    <img ng-src="{{item.avatarUrl}}" err-src="img/error.png" class="thumb-xs block img-circle m-b-xs"/>
                                    <span class="block h6 font-normal fa-border bg-success rounded" ng-if="item.isMainPromotion==1"><i class="fa fa-star text-warning"></i>主体</span>
                                </div>
                                <div class="pull-left text-left">
                                    <span class="block h5 font-bold m-b-xs w-sm">
                                            <span class="h6" ng-if="item.sex==2">--</span>
                                            <i class="icon-symbol-male text-info h6" ng-if="item.sex==1"></i>
                                            <i class="icon-symbol-female text-danger h6" ng-if="item.sex==0"></i>
                                            <span class="inline text-ellipsis w-xs">{{item.nickName}}</span>
                                    </span>
                                    <span class="block h6 m-b-xs w-sm">{{item.mobilePhone}}</span>
                                    <span class="block h6 w-sm font-bold text-ellipsis w-xs">{{item.name==null?'-- --':item.name}}</span>
                                </div>
                            </div>
                        </div>
                        <div class="panel-body text-center">
                            <button class="btn m-b-xs btn-danger btn-sm btn-rounded" ng-if="item.isMainPromotion!=1" ng-click="sendUserUnBindCode(item.id,item.mobilePhone)">解绑商家用户</button>
                            <button class="btn m-b-xs bg-light btn-sm btn-rounded" ng-if="item.isMainPromotion==1">主体账号无法解绑</button>
                        </div>
                    </div>
                    <div ng-if="!searchBindUserState&&bindUsers.length==0">
                        <div class="panel-body">
                            <span class="h6">:)暂时还未绑定用户</span>
                        </div>
                    </div>
                    <div>
                        <circle-loading ng-if="searchBindUserState"></circle-loading>
                    </div>
                </div>
            </div>
            <div class="m-t-sm" ng-show="addShow">
                <div>
                    <div class="padder-md padder-v bg-light m-b-sm">
                        <span class="font-bold">根据手机号绑定相应用户（主体账号绑定后将会无法解绑,请谨慎绑定）</span>
                    </div>
                    <form name="searchForm" class="form-horizontal form-validation padder-v">
                        <div class="form-group m-n">
                            <label class="col-sm-1 control-label">手机号</label>
                            <div class="col-sm-4">
                                <input type="text" name="phone" ng-model="phone" class="form-control m-b-xs" placeholder="请输入手机号码" maxlength="11" ng-pattern="/^1[34578]\d{9}$/">
                                <div ng-if="searchForm.phone.$touched">
                                    <div ng-if="searchForm.phone.$error.pattern" class="text-danger h6">请输入正确的手机号码</div>
                                </div>
                            </div>
                            <div class="col-sm-2">
                                <button type="submit" class="btn btn-success" ng-click="findByMobilePhone()" ng-disabled="searchForm.$invalid">查询</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div>
                    <div class="padder-md padder-v bg-light m-b-sm">
                        <span class="font-bold">查询结果</span>
                    </div>
                    <div>
                        <div class="inline fa-border" ng-if="searchUser!=null">
                            <div class="bg-white">
                                <div class="panel-body m-n">
                                    <div class="pull-left m-r-sm">
                                        <img src="{{searchUser.avatarUrl}}" err-src="img/error.png"  class="thumb-xs img-circle"/>
                                    </div>
                                    <div class="pull-left text-left">
                                        <span class="block h5 font-bold m-b-xs w-sm">
                                            <span class="h6" ng-if="searchUser.sex==2">--</span>
                                            <i class="icon-symbol-male text-info h6" ng-if="searchUser.sex==1"></i>
                                            <i class="icon-symbol-female text-danger h6" ng-if="searchUser.sex==0"></i>
                                            <span class="inline text-ellipsis w-xs">{{searchUser.nickName}}</span>
                                        </span>
                                        <span class="block h6 m-b-xs w-sm">{{searchUser.mobilePhone}}</span>
                                        <span class="block h6 w-sm font-bold text-ellipsis w-xs">{{searchUser.name==null?'-- --':searchUser.name}}</span>
                                    </div>
                                </div>
                            </div>
                            <div class="panel-body text-center">
                                <button class="btn m-b-xs bg-success btn-sm btn-rounded" ng-click="sendUserBindCode(searchUser.id)" ng-if="searchUser.isShop!=1">发送验证码,<p class="inline m-n" ng-if="bindUsers.length!=0">绑定用户</p><p class="inline m-n" ng-if="bindUsers.length==0">绑定主体账号</p></button>
                                <div class="btn m-b-xs bg-light btn-sm btn-rounded" ng-if="searchUser.isShop==1">用户已经绑定</div>
                            </div>
                        </div>
                        <div>
                            <circle-loading ng-if="searchState"></circle-loading>
                        </div>
                        <div ng-if="searchUser==null">
                            <div class="panel-body">
                                <span class="block h6">:)用户未找到</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>